// See https://cli.vuejs.org/guide/deployment.html

const CopyWebpackPlugin = require('copy-webpack-plugin');
const webpack = require('webpack')

module.exports = {
    devServer: {
        disableHostCheck: true,
        proxy: {
            '^/api': {
                target: 'http://192.168.66.30',
                // target: 'http://hs.tssdeyy.com',
                ws: true,
                changeOrigin: true,
                pathRewrite: {'^/api' : ''}
            },
        }
    },
    publicPath: (process.env.NODE_ENV === 'production' ? '/manage' : ''),
    configureWebpack: config => {
        if (process.env.NODE_ENV === 'production') {
            return {

                plugins: [
                    new webpack.DefinePlugin({
                        "TIMESTAMP": new Date().getTime().toFixed(0),
                    }),
                    new CopyWebpackPlugin([{
                        from: 'node_modules/@aspnet/signalr/dist/browser/signalr.min.js',
                        to: 'dist'
                    }, {
                        from: 'node_modules/abp-web-resources/Abp/Framework/scripts/libs/abp.signalr-client.js',
                        to: 'dist'
                    }, {
                        from: 'src/lib/abp.js',
                        to: 'dist'
                    }])
                ]
            }
        } else {
            return {
                plugins: [
                    new webpack.DefinePlugin({
                        "TIMESTAMP": new Date().getTime().toFixed(0),
                    }),
                    new CopyWebpackPlugin([{
                        from: 'node_modules/@aspnet/signalr/dist/browser/signalr.min.js',
                        to: 'dist'
                    }, {
                        from: 'node_modules/abp-web-resources/Abp/Framework/scripts/libs/abp.signalr-client.js',
                        to: 'dist'
                    }, {
                        from: 'src/lib/abp.js',
                        to: 'dist'
                    }])
                ]
            }
        }
    }
}